<?php
class Request {

	public function getPost() {
		$parameters = array();
		foreach ($_POST as $key => $value) {
			$parameters[$key] = addslashes($value);
		}
		return $parameters;
	}
	
	public function getArguments() {
		$config = new Config;

		#console or http!?
		if (empty($_SERVER["HTTP_USER_AGENT"])) {
			$request = $this->getConsoleOptions();
			$config->development	= true;
			$config->console		= true;
		} else {
			$request = $this->getHttpOptions();
		}
		
		if (isset($request[0])) {
			$config->mainClass = $request[0];
		}
		
		if (isset($request[1])) {
			$config->mainMethod = $request[1]; 
		}

		return (array) array_slice($request, 2);
	}
	
	private function getConsoleOptions() {
		return (array) array_slice($_SERVER["argv"], 1);
	}

	private function getHttpOptions() {
		if (isset($_SERVER["PATH_INFO"]) === false) {
			return (array) array();
		}
		$_SERVER["PATH_INFO"] = urldecode($_SERVER["PATH_INFO"]);
		return (array) array_slice(explode("/", $_SERVER["PATH_INFO"]), 1);
	}

}